import { BasicColumn, FormSchema } from '/@/components/Table';
// import { getPersonType } from '/@/views/emp/team/general/relationship/service';
import { render } from '/@/utils/common/renderUtils';
import { selectPersonTreeList } from './service';
import { getPersonTypeListByType } from '/@/api/common/api';
import { renderDict } from '../../../components/utils/index';

export const searchFormSchema: FormSchema[] = [
  // {
  //   field: 'posName',
  //   label: '任职岗位',
  //   component: 'Input',
  // },
  {
    field: 'personType',
    label: '人员类型',
    component: 'ApiSelect',
    componentProps: {
      // dictCode: 'hub_person_type2',
      // placeholder: '请选择用工性质',
      api: getPersonTypeListByType,
      fieldNames: {
        label: 'name',
        value: 'code',
      },
    },
  },
  // {
  //   field: 'psnNum',
  //   label: '员工工号',
  //   component: 'Input',
  // },
  {
    field: 'psnName',
    label: '员工姓名',
    component: 'Input',
  },
  {
    field: 'assess',
    label: '是否考核',
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '是',
          value: 'true',
        },
        {
          label: '否',
          value: 'false',
        },
      ],
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: 'id',
    dataIndex: 'id',
    width: 80,
    ifShow: false,
  },
  {
    title: '姓名',
    dataIndex: 'psnName',
    width: 200,
    align: 'center',
    fixed: 'left',
  },
  {
    title: '工号',
    dataIndex: 'psnNum',
    width: 140,
    align: 'center',
  },
  {
    title: '部门名称',
    dataIndex: 'orgName',
    align: 'center',
    width: 140,
  },
  {
    title: '任职岗位',
    dataIndex: 'posName',
    width: 140,
    align: 'center',
  },
  {
    title: '人员类型',
    dataIndex: 'personType',
    width: 200,
    align: 'center',
    customRender: ({ text }) => {
      return renderDict(text, ['hub_person_type1', 'hub_person_type2']);
    },
  },
  {
    title: '是否考核',
    dataIndex: 'assess',
    editRow: true,
    editComponent: 'Switch',
    width: 80,
    align: 'center',
  },
  {
    title: '不接受更新',
    dataIndex: 'notUpdate',
    editRow: true,
    editComponent: 'Switch',
    width: 110,
    align: 'center',
  },
  {
    title: '绩效兼职',
    dataIndex: 'epmPerson1Name',
    width: 140,
    align: 'center',
  },
  {
    title: '绩效经理',
    dataIndex: 'epmPerson2Name',
    width: 140,
    align: 'center',
  },
  {
    title: '绩效等级类型',
    dataIndex: 'perfLevelType',
    width: 200,
    align: 'center',
    customRender: ({ text }) => {
      return render.renderDict(text, 'hub_perf_level_type');
    },
  },
  {
    title: '绩效工资分配类型',
    dataIndex: 'prefSalaryType',
    width: 200,
    align: 'center',
    customRender: ({ text }) => {
      return render.renderDict(text, 'hub_pref_salary_type');
    },
  },
  {
    title: '绩效工资分配方式',
    dataIndex: 'prefSalaryWay',
    width: 200,
    align: 'center',
    customRender: ({ text }) => {
      return render.renderDict(text, 'hub_pref_salary_way');
    },
  },
  {
    title: '用工性质',
    dataIndex: 'userPosType',
    width: 200,
    align: 'center',
    customRender: ({ text }) => {
      return render.renderDict(text, 'epm_work_type');
    },
  },
  // {
  //   title: '是否主岗',
  //   dataIndex: 'mainpos',
  //   editRow: true,
  //   editComponent: 'Switch',
  //   width: 80,
  //   align: 'center',
  // },
  {
    title: '是否负责人',
    dataIndex: 'director',
    width: 120,
    align: 'center',
    editRow: true,
    editComponent: 'Switch',
  },
  {
    title: '排序',
    editRow: true,
    dataIndex: 'displayOrder',
    editComponent: 'InputNumber',
    align: 'center',
    width: 100,
  },
];

export const editForm: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '部门名称',
    component: 'Input',
    field: 'orgName',
    dynamicDisabled: () => true,
  },
  {
    label: '任职岗位',
    component: 'Input',
    field: 'posName',
    dynamicDisabled: () => true,
  },
  {
    label: '工号',
    field: 'psnNum',
    component: 'Input',
    dynamicDisabled: () => true,
  },
  {
    label: '姓名',
    field: 'psnName',
    component: 'Input',
    dynamicDisabled: () => true,
  },
  {
    field: 'personType',
    label: '人员类型',
    component: 'ApiSelect',
    componentProps: {
      // dictCode: 'hub_person_type2',
      // placeholder: '请选择用工性质',
      api: getPersonTypeListByType,
      fieldNames: {
        label: 'name',
        value: 'code',
      },
    },
  },
  {
    label: '绩效等级类型',
    field: 'perfLevelType',
    component: 'ZDictSelectTag',
    componentProps: {
      dictCode: 'hub_perf_level_type',
      placeholder: '请选择用工性质',
    },
  },
  {
    label: '绩效工资分配类型',
    field: 'prefSalaryType',
    component: 'ZDictSelectTag',
    componentProps: {
      dictCode: 'hub_pref_salary_type',
      placeholder: '请选择用工性质',
    },
  },
  {
    label: '绩效工资分配方式',
    field: 'prefSalaryWay',
    component: 'ZDictSelectTag',
    componentProps: {
      dictCode: 'hub_pref_salary_way',
      placeholder: '请选择用工性质',
    },
  },
  {
    label: '用工性质',
    field: 'userPosType',
    component: 'ZDictSelectTag',
    componentProps: {
      dictCode: 'epm_work_type',
      placeholder: '请选择用工性质',
    },
  },
  {
    field: 'epmPerson1Name',
    label: '绩效兼职',
    component: 'Input',
    show: false,
  },
  {
    field: 'epmPerson1Code',
    label: '绩效兼职编码',
    component: 'Input',
    show: false,
  },
  {
    label: '绩效兼职',
    field: 'epmPerson1',
    required: false,
    component: 'ZSelectCustom',
    componentProps: ({ formModel }) => {
      console.log('formModel', formModel);
      return {
        sync: true,
        queryApi: selectPersonTreeList,
        titleKey: 'title',
        rowKey: 'psnNum',
        multiple: false, //多选
        modalTitle: '人员选择',
        showSearch: true,
        maxTagCount: 3,
        // options: [{ label: formModel.managerName ? formModel.managerName : '', value: formModel.manager ? formModel.manager[0] : '' }],
        params: {
          type: '1',
        },
      };
    },
  },
  {
    field: 'epmPerson2Name',
    label: '绩效经理',
    component: 'Input',
    show: false,
  },
  {
    field: 'epmPerson2Code',
    label: '绩效经理编码',
    component: 'Input',
    show: false,
  },
  {
    label: '绩效经理',
    field: 'epmPerson2',
    required: false,
    component: 'ZSelectCustom',
    componentProps: ({ formModel }) => {
      console.log('formModel', formModel);
      return {
        sync: true,
        queryApi: selectPersonTreeList,
        titleKey: 'title',
        rowKey: 'psnNum',
        multiple: false, //多选
        modalTitle: '人员选择',
        showSearch: true,
        maxTagCount: 3,
        // options: [{ label: formModel.managerName ? formModel.managerName : '', value: formModel.manager ? formModel.manager[0] : '' }],
        params: {
          type: '1',
        },
      };
    },
  },
  {
    label: '是否考核',
    field: 'assess',
    component: 'ZSwitch',
    componentProps: {
      options: ['true', 'false'],
    },
  },
  {
    label: '不接受更新',
    field: 'notUpdate',
    component: 'ZSwitch',
    componentProps: {
      options: ['true', 'false'],
    },
  },
  // {
  //   label: '是否主岗',
  //   field: 'mainpos',
  //   component: 'ZSwitch',
  //   componentProps: {
  //     options: ['true', 'false'],
  //   },
  // },
  {
    label: '是否负责人',
    field: 'director',
    component: 'ZSwitch',
    componentProps: {
      options: ['true', 'false'],
    },
  },
  {
    label: '排序',
    field: 'displayOrder',
    component: 'InputNumber',
  },
];
